import {
  getToken,
  setToken,
  getUserInfo,
  setUserInfo,
  setRemoveToken,
  setRemoveUser
} from '@/utils/auth'

const state = {
  token: getToken(),
  userInfo: getUserInfo()
}
const mutations = {
  SET_TOKEN: (state, token) => {
    state.token = token
    setToken(token)
  },
  SET_USERINFO: (state, userInfo) => {
    state.userInfo = userInfo
    setUserInfo(userInfo)
  },
  REMOVE_TOKEN: (state, token) => {
    setRemoveToken(token)
  },
  REMOVE_USER: (state, userInfo) => {
    setRemoveUser(userInfo)
  }
}
const actions = {
  // login({ commit }, userInfo) {
  //   commit('SET_TOKEN', 'test')
  // }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
